package com.itheima.service.db.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.domain.db.UserStatus;
import com.itheima.mapper.UserManagementMapper;
import com.itheima.service.db.UserManagementService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class UserManagementServiceImpl implements UserManagementService {

    @Autowired
    private UserManagementMapper userManagementMapper;

    //添加冻结数据
    @Override
    public void saveUserStatus(UserStatus userStatus) {
        userManagementMapper.insert(userStatus);
    }

    //查找冻结详情
    @Override
    public UserStatus findById(Long userId) {
        LambdaQueryWrapper<UserStatus> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserStatus::getUserId, userId);
        UserStatus userStatus = userManagementMapper.selectOne(wrapper);
        return userStatus;
    }

    //删除冻结记录
    @Override
    public void delete(Long userId) {
        LambdaQueryWrapper<UserStatus> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserStatus::getUserId, userId);
        userManagementMapper.delete(wrapper);
    }

    //更新记录
    @Override
    public void update(UserStatus userStatus) {
        LambdaQueryWrapper<UserStatus> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserStatus::getUserId, userStatus.getUserId());
        userManagementMapper.update(userStatus,wrapper);
    }


}
